from timeit import Timer

import sys
import math


def Problem():
    """A palindromic number reads the same both ways. The largest palindrome 
    made from the product of two 2-digit numbers is 9009 = 91 * 99.

    Find the largest palindrome made from the product of two 3-digit numbers."""

    #The reverse of a palindrome is the same
    isPalindrome = lambda s: s == s[::-1]
    
    
    max = 0
    for m in range(999, 900, -1):
        for n in range(999, m-1, -1):
            result = str(m * n)
            if isPalindrome(result) and result > max:
                max = result
    
    print "Answer for Problem 4 = %s " % (max,)




    
if __name__ == "__main__":
    t = Timer(setup='from __main__ import Problem', stmt='Problem()').timeit(1)
    print "Execution time = %0.3f seconds" %(t,)